package com.whub507.msgmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whub507.msgmanager.common.ResResult;
import com.whub507.msgmanager.domain.User;
import com.whub507.msgmanager.mapper.UserMapper;
import com.whub507.msgmanager.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public ResResult<String> getDepartmentById(Integer userId) {
        User user = userMapper.selectById(userId);
        if (user == null)
            return ResResult.error(507, "该用户未找到");

        return ResResult.ok(user.getDepartment());
    }
}
